package com.zw.admin.server.utils;

import com.zw.admin.server.dto.Device.Iot;
import com.zw.admin.server.model.Device;
import com.zw.admin.server.model.DeviceHalfHour;

import java.sql.Timestamp;
import java.util.Date;

public class DeviceUtils {

    public static void Device2Iot(Device device, Iot iot) {

    }

    public static void Iot2Device(Iot iot ,Device device) {
        device.setIotId(iot.getIot_id());
        device.setAppId(iot.getApp_id());
        device.setAppName(iot.getApp_name());
        device.setGroupId(iot.getGroup_id());
        device.setGroupName(iot.getGroup_name());
        device.setHardVer(iot.getHardVer());
        device.setLastTime(new Timestamp(iot.getLastTime() == null ? new Date().getTime(): iot.getLastTime().getTime()));
        device.setName(iot.getName());
        device.setOnlineTime(new Timestamp(iot.getOnlineTime() == null? new Date().getTime(): iot.getOnlineTime().getTime()));
        device.setRootGroupId(iot.getRoot_group_id());
        device.setRootGroupName(iot.getRoot_group_name());
        device.setSoftVer(iot.getSoftVer());
        device.setStates(iot.getStates());
        device.setInsertTime(new Timestamp(iot.getLastTime() == null ? new Date().getTime() :iot.getLastTime().getTime()));
        device.setDataTemperature1(iot.getData().TEMPERATURE_1);
        device.setDataEnum1(iot.getData().getENUM_1());
        device.setDataLux1(iot.getData().getLUX_1());
        device.setDataMoisture1(iot.getData().getMOISTURE_1());
        device.setDataElectricity1(iot.getData().getELECTRICITY_1());
        device.setDataPowers1(iot.getData().getPOWERS_1());
        device.setDataQuantity1(iot.getData().getQUANTITY_1());
        device.setDataPowers1(iot.getData().getPOWERS_1());
        device.setDataVoltage1(iot.getData().getVOLTAGE_1());
        device.setDataCloudstateDevSwitchSta1(iot.getData().getCloud_state().getDEV_SWITCH_STA_1());
        device.setDataCloudstateEnum1(iot.getData().getCloud_state().getENUM_1());
        device.setDataCloudstateEnum2(iot.getData().getCloud_state().getENUM_2());
        device.setDataCloudstateEnum3(iot.getData().getCloud_state().getENUM_3());
        device.setDataCloudstateEnum4(iot.getData().getCloud_state().getENUM_4());
        device.setDataSyncstateDevSwitchSta1(iot.getData().getSync_state().getDEV_SWITCH_STA_1());
        device.setDataSyncstateEnum1(iot.getData().getSync_state().getENUM_1());
        device.setDataSyncstateEnum2(iot.getData().getSync_state().getENUM_2());
        device.setDataSyncstateEnum3(iot.getData().getSync_state().getENUM_3());
        device.setDataSyncstateEnum4(iot.getData().getSync_state().getENUM_4());
    }

    public static void Iot2DeviceHF(Iot iot , DeviceHalfHour deviceHF) {
        deviceHF.setIotId(iot.getIot_id());
        deviceHF.setAppId(iot.getApp_id());
        deviceHF.setAppName(iot.getApp_name());
        deviceHF.setGroupId(iot.getGroup_id());
        deviceHF.setGroupName(iot.getGroup_name());
        deviceHF.setHardVer(iot.getHardVer());
        deviceHF.setLastTime(new Timestamp(iot.getLastTime() == null ? new Date().getTime(): iot.getLastTime().getTime()));
        deviceHF.setName(iot.getName());
        deviceHF.setOnlineTime(new Timestamp(iot.getOnlineTime() == null? new Date().getTime(): iot.getOnlineTime().getTime()));
        deviceHF.setRootGroupId(iot.getRoot_group_id());
        deviceHF.setRootGroupName(iot.getRoot_group_name());
        deviceHF.setSoftVer(iot.getSoftVer());
        deviceHF.setStates(iot.getStates());
        deviceHF.setDataTemperature1(iot.getData().TEMPERATURE_1);
        deviceHF.setDataEnum1(iot.getData().getENUM_1());
        deviceHF.setDataLux1(iot.getData().getLUX_1());
        deviceHF.setDataMoisture1(iot.getData().getMOISTURE_1());
        deviceHF.setDataElectricity1(iot.getData().getELECTRICITY_1());
        deviceHF.setDataPowers1(iot.getData().getPOWERS_1());
        deviceHF.setDataQuantity1(iot.getData().getQUANTITY_1());
        deviceHF.setDataPowers1(iot.getData().getPOWERS_1());
        deviceHF.setDataVoltage1(iot.getData().getVOLTAGE_1());
        deviceHF.setDataCloudstateDevSwitchSta1(iot.getData().getCloud_state().getDEV_SWITCH_STA_1());
        deviceHF.setDataCloudstateEnum1(iot.getData().getCloud_state().getENUM_1());
        deviceHF.setDataCloudstateEnum2(iot.getData().getCloud_state().getENUM_2());
        deviceHF.setDataCloudstateEnum3(iot.getData().getCloud_state().getENUM_3());
        deviceHF.setDataCloudstateEnum4(iot.getData().getCloud_state().getENUM_4());
        deviceHF.setDataSyncstateDevSwitchSta1(iot.getData().getSync_state().getDEV_SWITCH_STA_1());
        deviceHF.setDataSyncstateEnum1(iot.getData().getSync_state().getENUM_1());
        deviceHF.setDataSyncstateEnum2(iot.getData().getSync_state().getENUM_2());
        deviceHF.setDataSyncstateEnum3(iot.getData().getSync_state().getENUM_3());
        deviceHF.setDataSyncstateEnum4(iot.getData().getSync_state().getENUM_4());
    }
}
